home *** CD-ROM | disk | FTP | other *** search
- /* filename: EKGmain.c
- *
- * This is tha main file for the system.
- */
-
- /* Assembly routine that presets the A5 register to a place in
- * RAM that we know to be a good spot for global data. As it
- * turns out, the A5 location is set below A7 (the stack pointer)
- * in our embedded system RAM
- */
- extern void InitA5Reg(void);
-
- typedef enum {
- ACQ_INHIBITED = 1,
- ACQ_ABORT = 2,
- OK = 3,
- ACQ_INCOMPLETE = 4,
- } STATUS;
-
- /* This typedef would need to be reversed for little-endian target machines
- */
- typedef struct {
- unsigned AcqHoldoff : 1 ; /* Read/Write bit 0 */
- unsigned AcqComplete : 1 ; /* Read ONLY bit 1 */
- unsigned AcqInProcess : 1 ; /* Read ONLY bit 2 */
- unsigned AcqStart : 1 ; /* Write ONLY bit 3 */
- unsigned AcqAbort : 1 ; /* Write ONLY bit 4 */
- unsigned unused : 3 ; /* unused bits 5-7 */
- } tAcqStatus;
-
- typedef unsigned char uint8;
- typedef unsigned char boolean;
-
- #ifdef _NOT_SIMULATING_
-
- #define ACQ_STATUS_REG_ADDR ( 0x00300000 )
-
- #endif
-
- tAcqStatus *AcqStatusReg;
-
- boolean TheCowsAreOutRoaming;
-
- /* Function protos
- */
- void InitGlobals();
- STATUS DoAnalysis();
- STATUS DoDisplay();
- STATUS DoAcquisition();
-
-
- /************************************************* main() *
- *
- *
- */
-
- void main()
- {
- STATUS Status;
-
- InitGlobals();
-
- /* Run power-on self tests here
- */
-
- /* attempt an acquisition, then analyze and display
- * if successful
- */
- while ( TheCowsAreOutRoaming ) {
-
- if ( (Status = DoAcquisition() ) == OK ) {
- (void) DoAnalysis();
- (void) DoDisplay();
- }
- else {
- while (1) {
- ; /* universal error trap ! */
- }
- }
-
- }
- }
-
- /****************************************** InitGlobals() *
- *
- * This routine sets up the globals (call it immediately).
- */
-
- void InitGlobals() {
-
- #ifdef _NOT_SIMULATING_
-
- InitA5Reg(); /* preset the global data register to RAM */
-
- /* set pointer to the hardware
- */
- AcqStatusReg = (tAcqStatus *) ACQ_STATUS_REG_ADDR;
- #endif
-
- /* init acq hardware
- */
- AcqStatusReg->AcqAbort = 1;
- AcqStatusReg->AcqHoldoff = 0;
- AcqStatusReg->AcqStart = 0;
-
- TheCowsAreOutRoaming = 1;
- }
-
- /******************************************* DoAnalysis() *
- *
- * This routine would extract measurement results from the
- * raw acquired data.
- */
-
- STATUS DoAnalysis() {
-
- static STATUS PriorAcq;
-
- PriorAcq = OK;
- return (OK);
- }
-
- /******************************************** DoDisplay() *
- *
- * This routine would display the data acquired.
- */
-
- STATUS DoDisplay() {
- return (OK);
- }
-
- /**************************************** DoAcquisition() *
- *
- * This routine manages the acquisition of data.
- */
-
- STATUS DoAcquisition() {
-
- #ifdef _NOT_SIMULATING_
-
- /* if acquisitions are inhibited, then forget it
- */
- if ( !AcqStatusReg->AcqHoldoff ) {
-
- /* start an acquisition
- */
- AcqStatusReg->AcqStart = 1;
-
- while ( AcqStatusReg->AcqInProcess ) {
- ; /* wait for the acq to finish */
- }
-
- /* check to see if acq was completed
- */
- if ( AcqStatusReg->AcqComplete ) {
- return (OK);
- }
- else {
- return (ACQ_INCOMPLETE);
- }
-
- }
- else { /* acqs are inhibited */
- return (ACQ_INHIBITED);
- }
-
- #else
-
- /* simulation routines would go in here */
-
- #endif /* _NOT_SIMULATING_ */
- }
-